package 力扣题库;

public class p258各位相加 {
    public int addDigits(int num) {
        int sum=0;
        while (num>=0) {
            //当 num小于10时，结束循环
            sum=0;
            sum += (num%10);
            sum += (num/10);
            num = sum;
        }
        return num;

    }
}
